package com.yinghuo.risk.frigate.core.info;

import com.yinghuo.risk.frigate.core.handler.CacheHandler;

/**
 * com.yinghuo.risk.frigate.core.info
 *
 * @author 白雨浓
 * date: 2018/10/18 15:19
 * content: 登录、登出事件
 */
public class UserLoginEvent<T extends UserLoginInfo> {

    private final CacheHandler<T> cacheHandler;

    public UserLoginEvent(CacheHandler<T> cacheHandler) {
        this.cacheHandler = cacheHandler;
    }

    public void login(String tokenId, T info) {
        cacheHandler.create(tokenId, info);
    }

    public void logout(String tokenId) {
        cacheHandler.remove(tokenId);
    }

    public T getUserInfo(String tokenId) {
        return cacheHandler.find(tokenId);
    }

    public void refresh(String tokenId) {
        cacheHandler.refresh(tokenId);
    }
}
